const Koa = require('koa');

const app = new Koa();

const static = require('koa-static');  //中间件

const path = require('path');

const Router = require('koa-router');

const router = new Router();

app.use(router.routes());

app.use(router.allowedMethods());

let util = require('./util/util.js');

//__dirname：指当前js文件所在的绝对路径
console.log("__dirname",__dirname)
console.log("process",process.cwd());
app.use(static(path.join(__dirname,'./public/'))); //不用ctx.url，因为携带参数

router.get('/api/list',async (ctx,next) => {
    ctx.body = '123'
})

app.listen(3000,() => {
    console.log("服务启动成功")
})